package com.csii.activiti.server.api;

import com.csii.activiti.server.api.vo.Result;
import com.csii.activiti.server.core.entity.db.ActFlowNodeKeyEntity;
import com.csii.activiti.server.core.service.FlowNodeKeyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags="秘钥接口")
@RestController
@RequestMapping("/${activity.basic.url:activiti}/flow/key")
public class FlowNodeKeyController {

    @Autowired
    private FlowNodeKeyService flowNodeKeyService;


    @ApiOperation("查询全部秘钥")
    @GetMapping("/queryFlowNodeKeyList")
    public Result<List<ActFlowNodeKeyEntity>> queryFlowNodeKeyList(){
        return Result.ok(flowNodeKeyService.queryFlowNodeKeyList());
    }

    @ApiOperation("编辑秘钥")
    @PostMapping("/editActFlowNodeKey")
    public Result editActFlowNodeKey(@RequestBody ActFlowNodeKeyEntity entity){
        flowNodeKeyService.editActFlowNodeKey(entity);
        return Result.ok();
    }

    @ApiOperation("删除秘钥")
    @PostMapping("/deleteActFlowNodeKey")
    public Result deleteActFlowNodeKey(@ApiParam("主键") @RequestParam("id") String id){
        flowNodeKeyService.deleteActFlowNodeKey(id);
        return Result.ok();
    }

    @ApiOperation("添加秘钥")
    @PostMapping("/addActFlowNodeKey")
    public Result addActFlowNodeKey(@RequestBody ActFlowNodeKeyEntity entity){
        flowNodeKeyService.addActFlowNodeKey(entity);
        return Result.ok();
    }


}
